<!DOCTYPE html>
<html>

<head>
    <#include "/yq/admin/components/meta.html" />
    <title>蓁奕科技 ${metaTitleSuffix!}</title>
    <#include "/yq/admin/components/stylesheets.html" />
    <style>
        .avatar-uploader .el-upload {
    border: 1px dashed #d9d9d9;
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
  }
  .avatar-uploader .el-upload:hover {
    border-color: #409EFF;
  }
  .avatar-uploader-icon {
    font-size: 28px;
    color: #8c939d;
    width: 178px;
    height: 178px;
    line-height: 178px;
    text-align: center;
  }
  .avatar {
    width: 178px;
    height: 178px;
    display: block;
  }
</style>
</head>

<body>
    <div id='app'>
        <el-container>
            <#assign menuIndex="4-1" />
            <#include "/yq/admin/components/menu.html" />
            <el-container>
                <#include "/yq/admin/components/header.html" />
                <el-main>
                    <template>
                        <el-form ref="form" :model="form" label-width="80px">
                            <el-row :gutter="20">
                                <el-col :span="24">
                                    <el-form-item label="APP" v-if="${userRole!2} === 0">
                                        <el-select v-model="form.appId" placeholder="请选择" :disabled="form.appId">
                                            <el-option v-for="item in apps" :key="item.id" :label="item.name" :value="item.id">
                                            </el-option>
                                        </el-select>
                                    </el-form-item>
                                </el-col>
                                <el-col :span="12">
                                    <el-form-item label="标题">
                                        <el-input v-model="form.name"></el-input>
                                    </el-form-item>
                                </el-col>
                                <el-col :span="12">
                                    <el-form-item label="副标题">
                                        <el-input v-model="form.account" type='text'></el-input>
                                    </el-form-item>
                                </el-col>
                                <el-col :span="12">
                                    <el-form-item label="手机">
                                        <el-input v-model="form.mobile"></el-input>
                                    </el-form-item>
                                </el-col>
                                <el-col :span="12">
                                    <el-form-item label="商户号">
                                        <el-input v-model="form.identifier" disabled></el-input>
                                    </el-form-item>
                                </el-col>
                                <el-col :span="24">
                                    <el-form-item label="简介">
                                        <el-input v-model="form.intro" type=textarea rows='5'></el-input>
                                    </el-form-item>
                                </el-col>
                                <el-col :span="24">
                                    <el-form-item label="封面">
                                        <el-upload class="avatar-uploader" :on-success="handleAvatarSuccess" :http-request='uploadQnFile' list-type='picture' :show-file-list="false">
                                            <img v-if="form.logo" :src="form.logo" class="avatar">
                                            <i v-else class="el-icon-plus avatar-uploader-icon"></i>
                                        </el-upload>
                                    </el-form-item>
                                </el-col>
                                <!-- <el-col :span="12">
                                    <el-form-item label="商品描述">
                                        <el-upload :http-request='onUploadSMImage' list-type="picture-card" :file-list="fileList2" :on-success="fileChanged" :on-remove='fileChanged'>
                                            <i class="el-icon-plus"></i>
                                        </el-upload>
                                    </el-form-item>
                                </el-col> -->
                                <el-col>
                                    <el-form-item>
                                        <el-button type="primary" @click="onSubmit">保存</el-button>
                                    </el-form-item>
                                </el-col>
                            </el-row>
                        </el-form>
                    </template>
                </el-main>
            </el-container>
        </el-container>
        <#include "/yq/admin/components/footer.html" />
    </div>
    <#include "/yq/admin/components/scripts.html" />
    <#include "/components/qiniu.html" />
    <script type="text/javascript">
    var vue = new Vue({
        el: '#app',
        data() {
            return {
                types: [{ label: '普通活动', value: 1 }],
                imgDatas: [],
                fileList2: [],
                dialogImageUrl: '',
                dialogVisible: false,
                images: [],
                imageUrl: null,
                form: toJson(`${data}`),
                apps: toJson(`${apps!}`)
            }
        },
        mounted: function() {
            if (this.form.images != '') {
                // this.images = this.form.images.split(';');
                // for (var idx = 0; idx < this.images.length; idx++) {
                //     var url = this.images[idx];
                //     if (url == '') {
                //         continue;
                //     }
                //     this.fileList2.push({ 'name': '', 'url': url })
                // }
            }
        },
        methods: {
            onSubmit() {
                if ('${userRole!2}' === '0' && !this.form.appId) {
                    msg("请选择APP");
                    return;
                }
                if (!this.form.name) {
                    msg("请输入标题");
                    return;
                }
                if (!this.form.account) {
                    msg("请输入副标题");
                    return;
                }
                if (!this.form.mobile) {
                    msg("请输入手机");
                    return;
                }
                var imgs = '';
                var param = {
                    shopId: this.form.id,
                    name: this.form.name,
                    account: this.form.account,
                    password: this.form.password,
                    intro: this.form.intro,
                    logo: this.form.logo,
                    mobile: this.form.mobile,
                    appId: this.form.appId
                }
                // console.log(param)
                var url = ''
                var ref = '${referer!""}'
                var url = '/yq/admin/shop/submit'
                axiosRequest(param, url, ref)
            },
            handleAvatarSuccess(res, file) {
                this.form.logo = res.data.url
                // this.form.cover = URL.createObjectURL(file.raw);
            },
        },
        filters: {
            fmt(date) {
                return date
            }
        }
    })
    </script>
    <script>
    // vue.tableData = ${items!};
    </script>
</body>

</html>